package demeter.improve;

import java.util.ArrayList;
import java.util.List;

public class Demeter2 {
    public static void main(String[] args) {
        Principal principal = new Principal();
        principal.printAll(new Teacher());
    }
}

/**
 * 校长
 */
class Principal{

    public List<Teacher> getAllTeacher(){
        List<Teacher> list = new ArrayList<>();
        for (int i = 0; i < 5; i++) {
            list.add(new Teacher(i));
        }
        return list;
    }

    public void printAll(Teacher teacher){
        List<Teacher> allTeacher = getAllTeacher();
        System.out.println("------所有老师编号-------");
        allTeacher.stream().map(Teacher::getId).forEach(System.out::println);
        teacher.printAll();

    }


}

/**
 * 老师
 */
class Teacher{
    public Teacher() {
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    private Integer id;

    public Teacher(Integer id) {
        this.id = id;
    }

    public List<Student> getAllStudent(){
        List<Student> list = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            list.add(new Student(i));
        }
        return list;
    }
    public void printAll(){
        List<Student> allStudent = this.getAllStudent();
        System.out.println("------所有学生编号-------");
        allStudent.stream().map(Student::getId).forEach(System.out::println);
    }
}

/**
 * 学生
 */
class  Student{
    private Integer id;

    public Student(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }
}